class CulturalHeritage::CareAndMaintenanceTypesController < ApplicationController
  before_filter :authenticate_user!
  # GET /cultural_heritage/care_and_maintenance_types
  # GET /cultural_heritage/care_and_maintenance_types.xml
  def index
    @title_view = 'Tipos de Cuidado y Mantenimiento'
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenanceType.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @cultural_heritage_care_and_maintenance_type }
    end
  end

  # GET /cultural_heritage/care_and_maintenance_types/1
  # GET /cultural_heritage/care_and_maintenance_types/1.xml
  def show
    @title_view = 'Tipos de Cuidado y Mantenimiento'
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenanceType.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @cultural_heritage_care_and_maintenance_type }
    end
  end

  # GET /cultural_heritage/care_and_maintenance_types/new
  # GET /cultural_heritage/care_and_maintenance_types/new.xml
  def new
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenanceType.new
    @title_view = 'Cuidado y Mantenimiento'

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @cultural_heritage_care_and_maintenance_type }
    end
  end

  # GET /cultural_heritage/care_and_maintenance_types/1/edit
  def edit
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenanceType.find(params[:id])
  end

  # POST /cultural_heritage/care_and_maintenance_types
  # POST /cultural_heritage/care_and_maintenance_types.xml
  def create
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenanceType.new(params[:cultural_heritage_care_and_maintenance_type])

    respond_to do |format|
      if @cultural_heritage_care_and_maintenance_type.save
        format.html { redirect_to(@cultural_heritage_care_and_maintenance_type, :notice => 'Care and maintenance type was successfully created.') }
        format.xml  { render :xml => @cultural_heritage_care_and_maintenance_type, :status => :created, :location => @cultural_heritage_care_and_maintenance_type }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @cultural_heritage_care_and_maintenance_type.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /cultural_heritage/care_and_maintenance_types/1
  # PUT /cultural_heritage/care_and_maintenance_types/1.xml
  def update
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenanceType.find(params[:id])

    respond_to do |format|
      if @cultural_heritage_care_and_maintenance_type.update_attributes(params[:cultural_heritage_care_and_maintenance_type])
        format.html { redirect_to(@cultural_heritage_care_and_maintenance_type, :notice => 'Care and maintenance type was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @cultural_heritage_care_and_maintenance_type.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /cultural_heritage/care_and_maintenance_types/1
  # DELETE /cultural_heritage/care_and_maintenance_types/1.xml
  def destroy
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenanceType.find(params[:id])
    @cultural_heritage_care_and_maintenance_type.destroy

    respond_to do |format|
      format.html { redirect_to(cultural_heritage_care_and_maintenance_types_url) }
      format.xml  { head :ok }
    end
  end

  def update_table
    @cultural_heritage_care_and_maintenance_type = CulturalHeritage::CareAndMaintenance.all
    render :partial => "table"
  end
end
